import React from 'react';
import GUtils from "@/utils";
import {Link} from "react-router-dom";

const Config = (Action) => {
    const Handlers = {
    }
    const columns = [
        {title:"ID",dataIndex:"id",width:60,render:v=>{
            let uid =(v+"").padStart(3,"0");
            return   <Link to={`detail/view?id=${uid}`}>{uid}</Link>
            }},

        {title:"类型",dataIndex:"type",width:90,render:v=>GUtils.dealEnumValue(v,"DocType") },
        {title:"标题",dataIndex:"title",width:220},
        {title:"最后更新",dataIndex:"updateTime",width:120,render:v=>GUtils.dateTimeFormatter(v)},
        {title:"状态",dataIndex:"enabled",width:60,render:v=>GUtils.renderEnabledValue(v)},

        {title: '操作',dataIndex: 'id',width: 120,render(id,vo){
                return <div>
                    {GUtils.renderEditLink(id,"mr-8")}
                    <a onClick={()=>GUtils.copy(vo.url)} className="ml-8 mr-8">复制链接</a>

                    {[1,2,10].includes(vo.type) &&<a onClick={()=>window.open(vo.url)} className="mr-8">预览</a>}

                    {GUtils.renderEnabledLink(vo, "文档" ,"title", Action)}
                </div>
            }},
    ];
    return {
        ...window.CONFIG.getPagerConfig(Action), columns
    };
};


export default Config;
